package com.example.busquerysystem.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.busquerysystem.R;
import com.example.busquerysystem.utils.HttpUtil;

public class InsertUserActivity extends AppCompatActivity implements View.OnClickListener{
    private Toolbar toolbar;
    private Button buttonInsert;
    private EditText username;
    private EditText password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_insert_user);
        toolbar = (Toolbar) findViewById(R.id.insertUser_toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle("");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        initView();
        buttonInsert.setOnClickListener(this);

    }

    public void initView(){
        username = (EditText) findViewById(R.id.insert_user_edit);
        password = (EditText) findViewById(R.id.insert_pwd_edit);
        buttonInsert = (Button) findViewById(R.id.inser_btn);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.inser_btn://注册按钮
                HttpUtil.AddUser(username.getText().toString().trim(),password.getText().toString().trim(),
                        InsertUserActivity.this);
                break;
        }
    }
}
